package com.dji.sdk.extensions.java.util.Objects;

import com.dji.sdk.extensions.java.util.Preconditions;
import manifold.ext.rt.api.Extension;

import java.util.Objects;

/**
 * @author 吴昊
 */
@Extension
public class ObjectsExtension {
    @Extension
    public static <T> T requireNonNullElse(T obj, T defaultObj) {
        return (obj != null) ? obj : Objects.requireNonNull(defaultObj, "defaultObj");
    }

    @Extension
    public static int checkFromIndexSize(int fromIndex, int size, int length) {
        return Preconditions.checkFromIndexSize(fromIndex, size, length, null);
    }

    @Extension
    public static int checkIndex(int index, int length) {
        return Preconditions.checkIndex(index, length, null);
    }
}
